package com.wbp.cms.core.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.wbp.cms.client.common.domain.DictionaryDO;
import com.wbp.cms.client.common.query.DictionaryQuery;


/**
 * @Description:
 * @Department:
 * @author andy.lhc
 * @date 2016年3月9日 下午4:42:28
 */
@Repository("dictionaryDAO")
public class DictionaryDAO extends BaseDao {

  public Long insert(DictionaryDO dictionaryDO) {
    super.insert("DictionaryMapper.insert", dictionaryDO);
    return dictionaryDO.getId();
  }

  public int update(DictionaryDO dictionaryDO) {
    return super.update("DictionaryMapper.update", dictionaryDO);
  }
  
  public int delete(Long id) {
    return super.delete("DictionaryMapper.delete", id);
  }

  public List<DictionaryDO> query(DictionaryQuery dictionaryQuery) {
    return super.selectList("DictionaryMapper.query", dictionaryQuery);
  }

  
  public List<DictionaryDO> queryMetaDictionary(DictionaryQuery dictionaryQuery) {
    return super.selectList("DictionaryMapper.queryMetaDictionary", dictionaryQuery);
  }
  
  public Integer queryCount(DictionaryQuery dictionaryQuery) {
    Object obj = super.selectOneObject("DictionaryMapper.queryCount", dictionaryQuery);
    return obj == null ? 0 : (Integer) obj;
  }

  public DictionaryDO load(Long dictionaryId) {
    Object obj = super.selectOneObject("DictionaryMapper.load", dictionaryId);
    return obj == null ? null : (DictionaryDO) obj;
  }

  public List<DictionaryDO> queryChildDictionary(Long dictionaryId) {
    DictionaryQuery dictionaryQuery = new DictionaryQuery();
    dictionaryQuery.setParentId(dictionaryId);
    return super.selectList("DictionaryMapper.query", dictionaryQuery);
  }

  public List<DictionaryDO> queryDictionaryByMoreThanValue(DictionaryQuery dictionaryQuery) {
    return super.selectList("DictionaryMapper.queryDictionaryByMoreThanValue", dictionaryQuery);
  }

}
